using System;
using System.Drawing;
using Diagram.Commands;
using Diagram.View;
using PetriDiagram.Shapes;

namespace PetriDiagram.Commands
{
    [Serializable]
    class EditNameCommand : ICommand<Shape>
    {
        #region ICommand<Shape> Members

        public void Execute( Diagram.View.Diagram diagram )
        {
            Shape s = diagram.GetFirstSelectedShape();
            ( s as NetElementShape ).EditName();
        }

        public Image Image
        {
            get
            {
                return null;
            }
        }

        public bool IsAvailable( Diagram.View.Diagram diagram )
        {
            Shape s = diagram.GetFirstSelectedShape();
            return ( diagram.SelectedShapes.Count == 1 && (s is TransitionShape || s is PlaceShape) );
        }

        public string Name
        {
            get { return CommandResources.EditNameText; }
        }

        #endregion
    }
}
